﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Globalization;
using WCF;
using System.Web.Security;
using System.Data;

namespace geekmeet
{
    /// <summary>
    /// Search page
    /// </summary>
    public partial class Search : System.Web.UI.Page
    {
        GeekMeetService wcf = new GeekMeetService();

        protected void Page_Load(object sender, EventArgs e)
        {
            List<InterestComposite> allInterests = wcf.GetAllInterests();

            //Displays all interests to make it possible to search based on them
            foreach (InterestComposite i in allInterests)
            {
                Page.ClientScript.RegisterStartupScript(
                   this.GetType(), "addInterest" + i.InterestName, "addSearchInterest('" + i.InterestID + "','" + i.InterestName + "');", true);
            }
        }

        /// <summary>
        /// Checks if user is premium, and has access to the 
        /// advanced matchingp function
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void CheckPremium(object sender, EventArgs e)
        {
            // Decide if user is premium
            bool IsPremium = Roles.IsUserInRole("premiumuser");

            if (IsPremium)
            {
                Response.Redirect("SearchResult.aspx?action=findsoulmate");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(
                   this.GetType(), "pleaseUpgrade", "pleaseUpgrade('Du måste vara premiummedlem för att kunna söka på din själsfrände.');", true);
            }
                
        }

      
    }
}